package com.imaker.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.imaker.domain.ModulesInfo;
import com.imaker.service.ModulesService;
import com.imaker.utils.Validate;

 /**
 * <p>程序名称：       ModulesAction.java</p>
 * <p>程序说明：       模块信息，包含模块的增删改查等</p>
 * <p>版权信息：       Copyright mayonghua</p>
 * <p>时间：          Nov 5, 2010 9:36:50 AM</p>	
 * @author：          mayonghua
 * @version：         Ver 0.1
 */
@Controller
@Scope("prototype")
public class ModulesAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	private ModulesInfo modulesInfo;
	@Autowired
	private ModulesService modulesService;
	private List<ModulesInfo> modulesList;//模块列表
	private String flag;

	
	/**
	 * 模块管理页面初始化
	 * @return
	 */
	public String init() throws Exception{
		return SUCCESS;
	}
	
	public String listTree() throws Exception {
		
		return SUCCESS;
	}
	
	/**
	 * 分页显示模块的内容
	 */
	public String listByPage() throws Exception {
		page = modulesService.listByPage(page);
		getRequest().setAttribute("page",page);
		return SUCCESS;
	}
	
	/**
	 * 预新建
	 */
	public String toSave() throws Exception {
		return SUCCESS;
	}
	
	/**
	 * 新建
	 * @return
	 * @throws Exception
	 */
	public String save() throws Exception{ 
		if(Validate.entityNotNull(modulesInfo))
		modulesService.save(modulesInfo);

		return SUCCESS;
	}
	
	/**
	 * 预修改
	 * @return
	 * @throws Exception
	 */
	public String toUpdate() throws Exception {
		if(Validate.entityNotNull(modulesInfo)){
		modulesInfo = modulesService.findById(modulesInfo);
		}
		return SUCCESS;
	}
	
	
	/**
	 * 修改
	 * @return
	 * @throws Exception
	 */
	public String update() throws Exception {
		if(Validate.entityNotNull(modulesInfo))
		modulesService.update(modulesInfo);
		
		return SUCCESS;
	}
	
	/**
	 * 删除
	 * @return
	 * @throws Exception
	 */
	public String delete() throws Exception {
		modulesService.delete(idList);
		return SUCCESS;
	}
	
	public ModulesInfo getModulesInfo() {
		return modulesInfo;
	}

	public void setModulesInfo(ModulesInfo modulesInfo) {
		this.modulesInfo = modulesInfo;
	}

	public ModulesService getModulesService() {
		return modulesService;
	}

	public void setModulesService(ModulesService modulesService) {
		this.modulesService = modulesService;
	}

	public List<ModulesInfo> getModulesList() {
		return modulesList;
	}

	public void setModulesList(List<ModulesInfo> modulesList) {
		this.modulesList = modulesList;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	
	
}
